import Qt 4.7

Item {
    id: container
    width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10

    Rectangle {
        id: content
        anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
        color: "transparent"
        smooth: true
        radius: 10
	
        Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }

        Image {id:img; source: isDir == "true"?"images/dossier.jpg":"images/file.jpg";  smooth: true ; width:50 ; height:50}
        
        Text {
	  id: label
	  anchors.verticalCenter: content.verticalCenter
	  anchors.left:img.right
	  text: name
	  color: "#193441"
	  font.pixelSize: 30
	}	
    }

    
    
    

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true

        onClicked: {
            ListView.view.currentIndex = index
            container.forceActiveFocus()
        }
    }

    Keys.onPressed: {
		if (event.key == Qt.Key_Return) {
		    console.log("selected :"  + name );
		    if(isDir == "true") {
			console.log("execute pwd");
			xmlModel.source="http://manu42.local:8084/LocalModel/findFiles.jsp?dir="+sPath+"&filter=avi";
		    }else{
		     var doc = new XMLHttpRequest();
		     doc.onreadystatechange = function() {
			 console.log(doc.readyState);
		     }
		     doc.open("GET", "http://manu42.local:8084/LocalModel/action.jsp?act=videoLancer&p1="+sPath);
		     doc.send();
		    }
		    event.accepted = true;
		}
    }
    
    states: State {
        name: "active"; when: container.activeFocus
        PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
        PropertyChanges { target: label; font.pixelSize: 16 }
    }

    transitions: Transition {
        NumberAnimation { properties: "scale"; duration: 100 }
    }
}
